/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.camara.jersey.Client;

import java.net.URI;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;



public class ClientRsJson {

    public static void main(String[] args) {
        ClientConfig config = new DefaultClientConfig();
         Client client = Client.create(config);
        WebResource service = client.resource(getBaseURI());
      
        // Get XML
        System.out.println(service.path("user").accept(MediaType.TEXT_XML).get(String.class));
        // Get XML for application
        System.out.println(service.path("user").accept(MediaType.APPLICATION_JSON).get(String.class));
        // Get JSON for application
        System.out.println(service.path("user").accept(MediaType.APPLICATION_XML).get(String.class));
    }

    private static URI getBaseURI() {
        return UriBuilder.fromUri("http://localhost:8080/com.camara.jersey").build();
    }

}
